﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SATF.DB;
using System.Data;

namespace SATF.BI
{
    public class BIModule : BaseItem
    {
        #region 所有成员属性

        private UInt64 m_product_id = 0;
        public UInt64 Product_ID
        {
            get { return m_product_id; }
            set
            {
                m_product_id = value;
                OnPropertyChanged("Product_ID");
            }
        }

        private BIProduct m_product = null;
        public BIProduct Product
        {
            get { return m_product; }
            set
            {
                m_product = value;
                OnPropertyChanged("Product");
            }
        }

        private string m_desc = "";
        public string Desc
        {
            get { return m_desc; }
            set
            {
                m_desc = value;
                OnPropertyChanged("Desc");
            }
        }

        private int m_isdeleted = 0;
        public int Isdeleted
        {
            get { return m_isdeleted; }
            set
            {
                m_isdeleted = value;
                OnPropertyChanged("Isdeleted");
            }
        }


        private string m_productName = "";
        public string ProductName
        {
            get { return m_productName; }
            set
            {
                m_productName = value;
                OnPropertyChanged("ProductName");
            }
        }


        #endregion


        #region 构造方法

        public BIModule()
            : base()
        {

        }

        public BIModule(UInt64 id)
            : base(id)
        {

        }

        public BIModule(string name)
            : base(name)
        {

        }

        public BIModule(DataRow dataRow)
            : base(dataRow)
        {

        }

        #endregion

        
        #region 基类方法

        public override void SetTableName()
        {
            this.TableName = "module";
        }

        public override string GetChildTable()
        {
            return "casefile";
        }

        public override void Fill(System.Data.DataRow dataRow)
        {
            ID = DBConvert.ToUInt64(dataRow, "ID");
            Name = DBConvert.ToString(dataRow, "Name");
            Product_ID = DBConvert.ToUInt64(dataRow, "Product_ID");
            Product = new BIProduct(Product_ID);
            ProductName = Product.Name;
            Desc = DBConvert.ToString(dataRow, "Desc");
            IsDeleted = DBConvert.ToInt32(dataRow, "IsDeleted");

            this.ContentDataRow = dataRow;
        }

        public override void UpdateContentDataRow()
        {
            this.ContentDataRow["Name"] = Name;
            this.ContentDataRow["Product_ID"] = Product_ID;
            this.ContentDataRow["Desc"] = Desc;
            this.ContentDataRow["IsDeleted"] = IsDeleted;

            this.ContentDataRow = this.ContentDataRow;
        }

        public override IList<BaseItem> GetChildren()
        {
            if (GetChildTable() == "")
            {
                return null;
            }
            IList<BaseItem> children = null;
            children = new BICaseFiles(DBFactory.QueryByDefault(this.GetChildTable(),
                    string.Format(" module_id like {0} and isdeleted like 0",
                    this.ID))).Children;

            return children;
        }

        #endregion


        #region 子类方法


        #endregion


        #region 一些查询方法


    


        #endregion
    }
}
